var num = 10;
var num2 = 2;
var res;
res = num + num2;
console.log(res);
num2++;
console.log(num2);
console.log(typeof num);
var string = 'san.' + 'zhang';
console.log(string);
var age = 12;
switch (age) {
    case 10:
        console.log("这是弟弟");
        break;
    case 12:
        console.log("这是自己");
        break;
    case 14:
        console.log("这是姐姐");
        break;
}
for (var i = 0; i < 5; i++) {
    if (i >= 5) {
        break;
    }
    else {
        console.log("i的值", i);
    }
}
function fun1() {
    console.log("调用fun1函数");
}
fun1();
function fun2() {
    return 'hello world!';
}
console.log(fun2());
function fun3(x, y, z) {
    if (z) {
        console.log("x+y", x + y);
    }
    else {
        console.log("x-y", x - y);
    }
}
fun3(10, 5, true);
//函数的可选参数
function fun4(firstname, lastname) {
    if (lastname) {
        return firstname + lastname;
    }
    else {
        return firstname;
    }
}
console.log(fun4('张'));
console.log(fun4('李', '四'));
//函数的默认参数
function fun5(firstname, lastname) {
    if (lastname === void 0) { lastname = '凌凌'; }
    return firstname + lastname;
}
console.log(fun5('张'));
console.log(fun5('李', '琳琳'));
//剩余参数
//将一个不确定数量的参数作为一个数组传入
function add() {
    var arr = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        arr[_i] = arguments[_i];
    }
    var nums = 0;
    for (var i = 0; i < arr.length; i++) {
        nums += arr[i];
    }
    return nums;
}
console.log(add(1, 2, 3));
console.log(add(10, 20, 10, 10));
//匿名函数
var msg = function (x, y) {
    console.log(x, y);
};
msg(false, "888");
//构造函数
var myFun = new Function("a", "b", "return a * b");
var ress = myFun(3, 4);
console.log(ress);
//Number
var a = Number(false);
console.log(a);
var b = 123.45678;
console.log(b.toFixed(3));
//String
var str = new String('cyh');
console.log(str, String('cyh'));
console.log(str.constructor);
console.log(String('cyh').length);
console.log(String.prototype);
console.log('str'.charAt(0));
//多维数组
var multiArr = [[1, 2, 3], [4, 5, 6]];
console.log(multiArr);
